import React, {PureComponent} from "react";
import { CloudDownloadOutlined, PaperClipOutlined } from '@ant-design/icons';
import { Button, Checkbox } from "antd";
import cs from "classnames";

const fileDesc = {
  PLT: 'PLT纸样文件',
  BOKE: '博克CAD文件'
}

export default class FileItem extends PureComponent {

  render() {

    const {
      readOnly, f, onFileCheck, isCheck, toDownload, type
    } = this.props


    return
    (
      <div className={'down-file-item plt'}>
        {
          readOnly
            ? undefined
            : <Checkbox value={f.id} onChange={onFileCheck(f)} checked={isCheck(f)}/>
        }
        <div>
          <PaperClipOutlined />
          {data.code}-{fileDesc[type]}
          {data.sizeName ? <b>{(data.sizeName)}</b> : undefined}
          <span className={cs('item-price', {bought: f['accessible']})}>
                                [ {f['accessible'] ? '已购买' : `￥${(data.pltPrice / 100 || 0).toFixed(2)}`} ]
                              </span>
        </div>
        {readOnly ? undefined :
          <Button type="link" icon={<CloudDownloadOutlined />} onClick={toDownload(f)}></Button>}
      </div>
    )
  }
}